package com.example.demo.contorller;

import com.example.demo.Repository.UserServiceJieKou;
import com.example.demo.entity.Blog;
import com.example.demo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserServiceJieKou userServiceJieKou;

    @GetMapping("/message")
    public User getMessage(@RequestParam("author") String author, @RequestParam("message") String message) {
        User user = new User();
        if ("jzman".equals(author) && "Hello".equals(message)) {
            user.setId(1L);
            user.setAuthor("Jack");
            user.setMessage("Hello");
        }
        return user;
    }

    @PostMapping("/test")
    public Blog test() {
        // 处理 POST 请求
        Blog blog = new Blog();
        blog.setId(2L);
        blog.setAuthor("Nacy");
        blog.setMessage("OK");
        return blog;
    }
}